"""
主要是封装项目运行Requests库
"""
import requests
import logging
class SDKClient:
    def __init__(self,methon,data):
        self.methon = methon
        self.data = data
    def do_request(self,url):
        # print(f"现在开始请求：{url},请求方法为：{self.methon},请求的参数为：{self.data}")
        # with open("api.log",mode='a',encoding='utf8') as f:
        #     f.write(f"现在开始请求：{url},请求方法为：{self.methon},请求的参数为：{self.data}\n")
        logging.basicConfig(filename="api.log",filemode="a",level="DEBUG")
        logging.info(f"现在开始请求：{url},请求方法为：{self.methon},请求的参数为：{self.data}\n")
        if self.methon =='get':
            return requests.get(url,params= self.data)
        elif self.methon =='post':
            return requests.post(url,json= self.data)